define(["jquery","bbcare"],function($,$bb){
	var quest = {};

	/**
	 * tpl模板
	 */
	quest.tpl = function(){
		return 	'<script id="tpl_question_staticAtualAge" type="text/html">'+
				'	<div {{if relationId}}relationId="{{relationId}}"{{/if}} class="qaCard form-group form-group-sm col-sm-{{length}} col-md-{{length}} grid-label-{{labelLength}}">'+
				'		<label class="control-label {{align}}">{{label}}</label>'+
				'   	<div class="control-input">'+
				'			<p class="form-control-static validatebox" name="{{id}}" data-type="{{type}}" data-validate="{{validate}}" data-attention="{{attention}}">{{val}}</p>'+
				'  		</div>'+
				'	</div>'+
				'</script>';
	}

	/**
	 * 处理value，获取年龄
	 */
	var handleVal = function($dom,value){
		var age;
		if ( value && value.match(/^((?!0000)[0-9]{4})-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$/) ){ 
            var curTime = $bb.simple.getCurTime().date;
            age = $bb.simple.dateDiff(value,curTime).age;
        }
        return age;
	}

	/**
	 * 赋值
	 */
	quest.setValue = function($dom,value){
		var value = handleVal($dom,value);
		$dom.html(value);
	}

	return quest;
});